﻿using AuthCenter.Api.Write.Application.Command.Apply;
using AuthCenter.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AuthCenter.Api.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ApplyController : ControllerBase
    {
        private readonly IMediator mediator;
        public ApplyController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 提交申请
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<ApiResult<int>> AddApply(AddApplyCommand request) 
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpDelete]
        public Task<ApiResult<int>> DeleteApply([FromQuery]DeleteApplyCommand request) 
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public Task<ApiResult<int>> UpdateApply(UpdateApplyCommand request) 
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改申请状态
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public Task<ApiResult<int>> UpdateApplyStatus(UpdateApplyStatusCommand request) 
        {
            return mediator.Send(request);
        }
    }
}
